
$(function() {
    $( "#fecha_ingreso" ).datepicker({ dateFormat: "yy-mm-dd" });
});

function flepues_usar_carnet(){
    var options = E('categoria_id').options;
    var auto_code = A(options[options.selectedIndex],'data-code');
    if(auto_code === '1'){
	A(E('clave'), 'disabled', 'disabled');
	A(E('clave2'), 'disabled', 'disabled');
    } else {
	E("clave").value = E("carnet").value;
        E("clave2").value = E("carnet").value;
	RA(E('clave'), 'disabled');
	RA(E('clave2'), 'disabled');
    }
}

function flepues_validar_estudiante(){
    if(E("clave").value !== E("clave2").value){
        E("clave").style.boxShadow = "rgb(255, 0, 0) 0px 0px 1.5px 1px";
	E("clave2").style.boxShadow = "rgb(255, 0, 0) 0px 0px 1.5px 1px";
	E("perror").innerHTML = "Las claves no son iguales";
	return false;
    }
    return true;
}

function flep_set_autocode(){
    var options = E('categoria_id').options;
    var auto_code = A(options[options.selectedIndex],'data-code');
    if(auto_code === '1'){
	if (E("id").value !== "") {
	    E('carnet').value = E('carnet').defaultValue;
	} else {
	    E('carnet').value = 'Automatico';
	}
	A(E('carnet'), 'disabled', 'disabled');
    } else {
	RA(E('carnet'), 'disabled');
	RA(E('clave'), 'disabled');
	RA(E('clave2'), 'disabled');
	E('carnet').value = '';
    }
}

function flep_generate_code(){
    if (E("id").value === "") {
        var options = E('categoria_id').options;
        var auto_code = A(options[options.selectedIndex],'data-code');
        if(auto_code === '1'){
            A(E("code").parentNode, "class", "autocode");
            E("code").value = "";
        } else {
            A(E("code").parentNode, "class", "");
        }
    }
}
